package com.heima.behavior.controller.v1;

import com.heima.behavior.service.*;
import com.heima.model.article.dtos.ArticleHomeDTO;
import com.heima.model.behavior.dtos.*;
import com.heima.model.common.constants.article.ArticleConstants;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "文章行为api", value = "文章行为api")
@RestController
@RequestMapping("/api/v1/")
public class ApLikesBehaviorController {
    @Autowired
    private ApLikesBehaviorService apLikesBehaviorService;

    @Autowired
    private ApReadBehaviorService apReadBehaviorService;

    @Autowired
    private ApUnlikeBehaviorService apUnlikeBehaviorService;

    @Autowired
    private ApCollectionBehaviorService apCollectionBehaviorService;

    @Autowired
    private ApArticleBehaviorService apArticleBehaviorService;

    @ApiOperation(value = "文章点赞列表", notes = "点赞和取消点赞")
    @PostMapping("/likes_behavior")
    public ResponseResult load(@RequestBody LikesBehaviorDTO dto) {
        return apLikesBehaviorService.like(dto);
    }

    @ApiOperation(value = "文章阅读行为", notes = "文章阅读行为")
    @PostMapping("/read_behavior")
    public ResponseResult read(@RequestBody ReadBehaviorDTO dto) {
        return apReadBehaviorService.readBehavior(dto);
    }


    @ApiOperation(value = "保存或取消不喜欢行为", notes = "保存或取消不喜欢行为")
    @PostMapping("/un_likes_behavior")
    public ResponseResult unLike(@RequestBody UnLikesBehaviorDTO dto) {
        return apUnlikeBehaviorService.unlikeBehavior(dto);
    }

    @ApiOperation(value = "保存或取消收藏行为", notes = "保存或取消收藏行为")
    @PostMapping("/collection_behavior")
    public ResponseResult collection(@RequestBody CollectionBehaviorDTO dto) {
        return apCollectionBehaviorService.collectBehavior(dto);
    }

    @ApiOperation(value = "查询文章行为相关信息", notes = "查询文章行为相关信息")
    @PostMapping("/article/load_article_behavior")
    public ResponseResult behavior(@RequestBody ArticleBehaviorDTO dto) {
        return apArticleBehaviorService.loadArticleBehavior(dto);
    }


}
